package com.dq.health.enums;

import java.util.EnumMap;
import java.util.Objects;

public enum GeneratorIdTypeEnum {
    /** 处方单 */
    PO("PRESCRIPTION_ORDER"),

    /** 预约单 */
    OO("OUTPATIENT_ORDER");

    private String value;

    private static final EnumMap<GeneratorIdTypeEnum, String> TEXT_MAP = new EnumMap<>(GeneratorIdTypeEnum.class);
    static {
        TEXT_MAP.put(GeneratorIdTypeEnum.PO, "处方单");
        TEXT_MAP.put(GeneratorIdTypeEnum.OO, "预约单");
    }

    GeneratorIdTypeEnum(String value) {
        this.value = value;
    }

    public static GeneratorIdTypeEnum parse(String value) {
        for (GeneratorIdTypeEnum spendingType : GeneratorIdTypeEnum.values()) {
            if (Objects.equals(value, spendingType.value)) {
                return spendingType;
            }
        }
        throw new RuntimeException("无法解析的单据类型值 value=" + value);
    }

    public String value() {
        return value;
    }

    @Override
    public String toString() {
        return TEXT_MAP.get(this);
    }
}
